<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/OrderStatusAnalysis/orderStatusAnalysis" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="orderStatusAnalysis" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label >订单号：</label>&nbsp;
            <input type="text" name="docId"  value="${docId}"/>
            <label >存货编码：</label>&nbsp;
            <input type="text" name="partName" value="${partName}"/>
        %{--<g:select name="partName" from="${orderStatusAnalysisPartName}" data-toggle="selectpicker" data-live-search="true" optionKey="part_name" optionValue="part_name" value="${partName}" noSelection="['':'ALL']" />&nbsp;--}%
            <label >产品名称：</label>&nbsp;
            <input type="text" name="partDesc" value="${partDesc}"/>
        %{--<g:select name="partDesc" from="${orderStatusAnalysisPartDesc}" data-toggle="selectpicker" data-live-search="true" optionKey="part_desc" optionValue="part_desc" value="${partDesc}" noSelection="['':'ALL']" />&nbsp;--}%
            <label >图号：</label>&nbsp;
            <input type="text" name="group3" value="${group3}"/>
        %{--<g:select name="group3" from="${orderStatusAnalysisGroupList}" data-toggle="selectpicker" data-live-search="true" optionKey="group3" optionValue="group3" value="${group3}" noSelection="['':'ALL']" />&nbsp;--}%
            <label >订单状态：</label>&nbsp;

        <g:select name="startedState" from="${orderStatusAnalysisStartedList}" data-toggle="selectpicker" data-live-search="true" optionKey="DOC_STATUS" optionValue="doc_state" value="${startedState}" noSelection="['':'ALL']" />&nbsp;
            <label >计划完成日期：</label>&nbsp;
            <input type="text" name="startTime" value="${startTime}" data-pattern="yyyy/MM/dd"  data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="endTime" value="${endTime}" data-pattern="yyyy/MM/dd" data-toggle="datepicker" placeholder="TO">&nbsp;&nbsp;
            <label >订单审核日期：</label>&nbsp;
            <input type="text" name="start" value="${start}" data-pattern="yyyy/MM/dd" data-toggle="datepicker" placeholder="FROM">
            <input type="text" name="end" value="${end}" data-pattern="yyyy/MM/dd" data-toggle="datepicker" placeholder="TO">&nbsp;&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/StageWip/exportExcel')" data-icon="file-excel-o" title="导出Excel">导出</button>&nbsp;
        </div>
    </form>
</div>

<div class="bjui-pageContent">
    <g:if test="${orderStatusAnalysis.size() > 0}">
        <table  data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th  width="125"><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${orderStatusAnalysis.size()>0}">
                <g:each in="${orderStatusAnalysis}" status="i" var="dataInstance">
                    <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">


                            <g:if test="${headInstance=='WAIT_QTY'&&headInstance!='RN'}">
                                <td name="tdwait${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisStep?docId1=<%=dataInstance.DOC_ID%>&state1=WAIT&holdState1=Off&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:if>
                            <g:elseif test="${headInstance=='DOC_QTY'&&headInstance!='RN'}">
                                <td name="tdorder${i}">${dataInstance["${headInstance}"] }</td>
                            </g:elseif>

                            <g:elseif test="${headInstance=='PRE_QTY'&&headInstance!='RN'}">
                                <td name="tdpre${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisPreStep?docId1=<%=dataInstance.DOC_ID%>&pre1=PRE&state1=pre&holdState1=pre&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='RUN_QTY'&&headInstance!='RN'}">
                                <td name="tdrun${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisStep?docId1=<%=dataInstance.DOC_ID%>&state1=RUN&holdState1=Off&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='REPAIR_QTY'&&headInstance!='RN'}">
                                <td name="tdrepair${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisStep?docId1=<%=dataInstance.DOC_ID%>&state1=REPAIR&holdState1=Off&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='OUTSRC_QTY'&&headInstance!='RN'}">
                                <td name="tdoutsrc${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisStep?docId1=<%=dataInstance.DOC_ID%>&state1=OUTSRC&holdState1=On&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='SBD_QTY'&&headInstance!='RN'}">
                                <td name="tdscrap${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisStep?docId1=<%=dataInstance.DOC_ID%>&scrap1=SCRAP&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='FIN_QTY'&&headInstance!='RN'}">
                                <td name="tdfin${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisStep?docId1=<%=dataInstance.DOC_ID%>&fin1=FIN&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='HOLD_QTY'&&headInstance!='RN'}">
                                <td name="tdhold${i}"><a href="${request.getContextPath()}/OrderStatusAnalysis/OrderStatusAnalysisStep?docId1=<%=dataInstance.DOC_ID%>&hold1=hold&lineNum=<%=dataInstance.LINE_NUM%>" data-toggle="navtab"  data-id="dialog-normal" data-options="{id:'orderStatusAnalysis', title:'订单状况分析表工序信息'}">${dataInstance["${headInstance}"] }</a></td>
                            </g:elseif>

                            <g:elseif test="${headInstance!='RN'}">
                                <td name="td${i}${j}">${dataInstance["${headInstance}"] }</td>
                            </g:elseif>

                        </g:each>
                    </tr>

                </g:each>
                <tr>
                    <td colspan="11">小计(当前页)</td>
                    <td name="orderSum">0</td>
                    <td name="preSum">0</td>
                    <td name="waitSum">1</td>
                    <td name="runSum">1</td>
                    <td name="holdSum">1</td>
                    <td name="repairSum">1</td>
                    <td name="outsrcSum">0</td>
                    <td name="scrapSum">0</td>
                    <td name="finSum">0</td>
                </tr>
                <tr>
                    <td colspan="11">合计(总)</td>
                    <td >${orderStatusAnalysisSum[0].SUM_DOC}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_PRE}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_WAIT}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_RUN}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_HOLD}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_REPAIR}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_OUTSRC}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_SBD}</td>
                    <td>${orderStatusAnalysisSum[0].SUM_FIN}</td>
                </tr>

            </g:if>
            <g:else>
                <g:render template="../template/emptyPanel" />
            </g:else>
            </tbody>
        </table>
    </g:if>
</div>
<g:render template="../template/51pagination" />
<script>
    $(function(){

        var waitSum=0;
        var preSum=0;
        var runSum=0;
        var holdSum=0;
        var repairSum=0;
        var outsrcSum=0;
        var scrapSum=0;
        var finSum=0;
        var orderSum=0;
        for(var i=0;i<${orderStatusAnalysis.size()};i++){

            var wait='tdwait'+i
            var sumWait=$("td[name='"+wait+"']").text()==''?0:parseInt($("td[name='"+wait+"']").text())
            waitSum+=sumWait
            var run='tdrun'+i
            var sumRun=$("td[name='"+run+"']").text()==''?0:parseInt($("td[name='"+run+"']").text())
            runSum+=sumRun
            var hold='tdhold'+i
            var sumHold=$("td[name='"+hold+"']").text()==''?0:parseInt($("td[name='"+hold+"']").text())
            holdSum+=sumHold
            var repair='tdrepair'+i
            var sumRepair=$("td[name='"+repair+"']").text()==''?0:parseInt($("td[name='"+repair+"']").text())
            repairSum+=sumRepair
            var outsrc='tdoutsrc'+i
            var sumOutsrc=$("td[name='"+outsrc+"']").text()==''?0:parseInt($("td[name='"+outsrc+"']").text())
            outsrcSum+=sumOutsrc
            var scrap='tdscrap'+i
            var sumScrap=$("td[name='"+scrap+"']").text()==''?0:parseInt($("td[name='"+scrap+"']").text())
            scrapSum+=sumScrap
            var fin='tdfin'+i
            var sumFin=$("td[name='"+fin+"']").text()==''?0:parseInt($("td[name='"+fin+"']").text())
            finSum+=sumFin
            var order='tdorder'+i
            var sumOrder=$("td[name='"+order+"']").text()==''?0:parseInt($("td[name='"+order+"']").text())
            orderSum+=sumOrder
            var pre='tdpre'+i
            var sumPre=$("td[name='"+pre+"']").text()==''?0:parseInt($("td[name='"+pre+"']").text())
            preSum+=sumPre
        }



        $("td[name='waitSum']").html(waitSum);
        $("td[name='runSum']").html(runSum);
        $("td[name='holdSum']").html(holdSum);
        $("td[name='repairSum']").html(repairSum);
        $("td[name='outsrcSum']").html(outsrcSum);
        $("td[name='scrapSum']").html(scrapSum);
        $("td[name='finSum']").html(finSum);
        $("td[name='orderSum']").html(sumOrder);
        $("td[name='preSum']").html(preSum);
        $("td[name='orderSum']").html(orderSum);
    })
</script>
